package nix.enum_;

/**
 * 枚举对象、下标、名称互相转换
 * 
 * @author berry
 * 
 */
public class TestEnumOperation {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		test1();
		test2();
		test3();
	}

	public static void test1() {
		Color4 color = Color4.GREEN;
		System.out.println(color.name());
		System.out.println(color.ordinal());
	}

	public static void test2() {
		Color4 color = Color4.valueOf("GREEN");
		System.out.println(color.ordinal());
	}

	public static void test3() {
		Color4 color = Color4.values()[1];
		System.out.println(color.name());
	}
}

enum Color4 {
	RED, GREEN, YELLOW;
}